package servlet;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import newsDB.NewsDao;
import newsEntity.News;

public class LeftServlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = -8551578864364218324L;

	/**
	 * Constructor of the object.
	 */
	public LeftServlet() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		java.util.Map<String, List<News>> newsMap = new HashMap<String, List<News>>();
		newsMap.put("1", NewsDao.nd.NewsForNtid(1L));
		newsMap.put("2", NewsDao.nd.NewsForNtid(2L));
		newsMap.put("5", NewsDao.nd.NewsForNtid(5L));
		request.setAttribute("newsMap", newsMap);
		request.getRequestDispatcher("/WEB-INF/jsp/left.jsp").include(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		this.doGet(request, response);
	}

	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException
	 *             if an error occurs
	 */
	public void init() throws ServletException {
		// Put your code here
	}

}
